import { createStore } from 'vuex';

const store = createStore({
    state: {
        token: localStorage.getItem('token') || ''
    },
    mutations: {
        SET_TOKEN(state, token) {
            state.token = token;
            localStorage.setItem('token', token);
        }
    },
    actions: {
        login({ commit }, token) {
            commit('SET_TOKEN', token);
        }
    }
});

export default store;